package com.bestom.bluetoothlock.views;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.Nullable;
import com.alibaba.fastjson.asm.Opcodes;

import java.util.ArrayList;
import java.util.List;

public class SpreadView extends View {
    private int addRadius;
    private List<Integer> alphas;
    private Paint centerPaint;
    private float centerX;
    private float centerY;
    private String content;
    private TextPaint contentPaint;
    private int delayMilliseconds;
    private int distance;
    private int maxRadius;
    private int radius;
    private Paint spreadPaint;
    private List<Integer> spreadRadius;

    public SpreadView(Context context) {
        this(context, (AttributeSet) null, 0);
    }

    public SpreadView(Context context, @Nullable AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public SpreadView(Context context, @Nullable AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.content = "";
        this.radius = 100;
        this.distance = 5;
        this.addRadius = 5;
        this.maxRadius = 90;
        this.delayMilliseconds = 33;
        this.spreadRadius = new ArrayList<>();
        this.alphas = new ArrayList<>();
        int color = Color.BLACK;
        int color2 = Color.BLACK;
        int color3 = Color.WHITE;
        this.centerPaint = new Paint();
        this.centerPaint.setColor(color);
        this.centerPaint.setAntiAlias(true);
        this.contentPaint = new TextPaint();
        this.contentPaint.setColor(color3);
        this.contentPaint.setTextSize(40.0f);
        this.contentPaint.setTextAlign(Paint.Align.CENTER);
        this.alphas.add(Integer.valueOf(Opcodes.IF_ICMPNE));
        this.spreadRadius.add(0);
        this.spreadPaint = new Paint();
        this.spreadPaint.setAntiAlias(true);
        this.spreadPaint.setAlpha(255);
        this.spreadPaint.setColor(color2);
    }

    public void setContent(String str) {
        this.content = str;
    }

    /* access modifiers changed from: protected */
    public void onSizeChanged(int i, int i2, int i3, int i4) {
        super.onSizeChanged(i, i2, i3, i4);
        this.centerX = (float) (i / 2);
        this.centerY = (float) (i2 / 2);
    }

    /* access modifiers changed from: protected */
    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        int i = 0;
        while (true) {
            int i2 = 1;
            if (i >= this.spreadRadius.size()) {
                break;
            }
            int intValue = this.alphas.get(i).intValue();
            this.spreadPaint.setAlpha(intValue);
            int intValue2 = this.spreadRadius.get(i).intValue();
            canvas.drawCircle(this.centerX, this.centerY, (float) (this.radius + intValue2), this.spreadPaint);
            if (intValue > 0 && intValue2 < 300) {
                int i3 = this.distance;
                if (intValue - i3 > 0) {
                    i2 = intValue - i3;
                }
                this.alphas.set(i, Integer.valueOf(i2));
                this.spreadRadius.set(i, Integer.valueOf(intValue2 + this.addRadius));
            }
            i++;
        }
        List<Integer> list = this.spreadRadius;
        if (list.get(list.size() - 1).intValue() > this.maxRadius) {
            this.spreadRadius.add(0);
            this.alphas.add(Integer.valueOf(Opcodes.IF_ICMPNE));
        }
        if (this.spreadRadius.size() >= 6) {
            this.alphas.remove(0);
            this.spreadRadius.remove(0);
        }
        canvas.drawCircle(this.centerX, this.centerY, (float) this.radius, this.centerPaint);
        canvas.drawText(this.content, this.centerX, this.centerY - ((this.contentPaint.descent() + this.contentPaint.ascent()) / 2.0f), this.contentPaint);
        postInvalidateDelayed(this.delayMilliseconds);
    }
}
